feat: 581 - allow to implement different Asserts functions. implement some more assert utility functions#589
feat: 581 - allow to implement different Asserts functions. implement some more assert utility functions#589KammutierSpule wants to merge 6 commits intorokath:mainfrom
Conversation
… some more assert utility functions
|
Is this a typo? Did this PASS the ./testAll.sh script: break; case __LINE__: (void)Test_triceAssertOrReturnValue(0); //exp: "time: default: ASSERT:flag not true!\n"
break; case __LINE__: (void)Test_TriceAssertOrReturnValue(0); //exp: "time: be16default: ASSERT:flag not true!\n"
break; case __LINE__: (void)Test_TRiceAssertOrReturnValue(0); //exp: "time:feed3322default: ASSERT:flag not true!\n"The |
|
Still exists: void triceAssertFail(int idN) {
TRICE_ASSERT(id(idN));
}
void TriceAssertFail(int idN) {
TRICE_ASSERT(Id(idN));
}
void TRiceAssertFail(int idN) {
TRICE_ASSERT(ID(idN));
} |
Not a typo, it was to avoid warnings (not used return), but its ok I removed as there are no warnings on this test file. tests are passing: |
I didn't understood it previously the issue, could you explain again? |
|
Not sure about this triceOff.h extension: // ----- Arity detection helpers (C99) -----
#define _TRICE_PP_NARG_IMPL( \
_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
N, ...) N
#define _TRICE_PP_NARG(...) \
_TRICE_PP_NARG_IMPL(__VA_ARGS__, \
20,19,18,17,16,15,14,13,12,11, \
10,9,8,7,6,5,4,3,2,1,0)
#define _TRICE_PP_CAT(a,b) a##b
#define _TRICE_PP_OVERLOAD(name, count) _TRICE_PP_CAT(name, count)
#define _TRICE_PP_DISPATCH(name, ...) \
_TRICE_PP_OVERLOAD(name, _TRICE_PP_NARG(__VA_ARGS__))(__VA_ARGS__)
// triceAssertOrReturn
#define triceAssertOrReturn2(msg, flag) do {if (!(flag)) {return;}} while(0)
#define TriceAssertOrReturn2(msg, flag) do {if (!(flag)) {return;}} while(0)
#define TRiceAssertOrReturn2(msg, flag) do {if (!(flag)) {return;}} while(0)
#define triceAssertOrReturn3(idN, msg, flag) do {if (!(flag)) {return;}} while(0)
#define TriceAssertOrReturn3(idN, msg, flag) do {if (!(flag)) {return;}} while(0)
#define TRiceAssertOrReturn3(idN, msg, flag) do {if (!(flag)) {return;}} while(0)
#define triceAssertOrReturn(...) _TRICE_PP_DISPATCH(triceAssertOrReturn, __VA_ARGS__)
#define TriceAssertOrReturn(...) _TRICE_PP_DISPATCH(TriceAssertOrReturn, __VA_ARGS__)
#define TRiceAssertOrReturn(...) _TRICE_PP_DISPATCH(TRiceAssertOrReturn, __VA_ARGS__)
// triceAssertOrReturnValue
#define triceAssertOrReturnValue3(msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define TriceAssertOrReturnValue3(msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define TRiceAssertOrReturnValue3(msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define triceAssertOrReturnValue4(idN, msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define TriceAssertOrReturnValue4(idN, msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define TRiceAssertOrReturnValue4(idN, msg, flag, value) do {if (!(flag)) {return (value);}} while(0)
#define triceAssertOrReturnValue(...) _TRICE_PP_DISPATCH(triceAssertOrReturnValue, __VA_ARGS__)
#define TriceAssertOrReturnValue(...) _TRICE_PP_DISPATCH(TriceAssertOrReturnValue, __VA_ARGS__)
#define TRiceAssertOrReturnValue(...) _TRICE_PP_DISPATCH(TRiceAssertOrReturnValue, __VA_ARGS__)Please add a few explaining words. |
It looks it is the same purpose of what is on triceOn.h "The variadic macros" I guess I should reuse it from triceOn.h.. maybe extracting those definitions and try to reuse it |
|
I run
|
My comment in PR585:
|
|
Why not simply in `triceOff.h*: #define triceAssertOrReturn(...)
#define TriceAssertOrReturn(...)
#define TRiceAssertOrReturn(...) ? Do not trust the AI too much! It is VERY helpful but NEEDS a critical review afterwards. |
because of the "OrReturn" |
You suggestion to remove triceAssertFail and keep the triceAssertTrue ? |
|
We have void triceAssertTrue(int idN, const char* msg, int flag); // ok
void triceAssertFalse(int idN, const char* msg, int flag); // ok
void triceAssert(int idN, const char* msg, int flag); // ok
void triceAssertFail(int idN); // WRONG!!! |
I see...! Ok now I got the point. Probably a part of the AI conversation you had would be very helpful for other developers for understanding the additional triceOff.h code. Not everyone is a C macro expert. So please add a few explainig lines there too. |
|
I right now pushed an update into the main branch. |
Suggestion fix for #581